function derivs=f_d1(vars,params,index)
c_cup=vars(1);
r_cup=vars(2);
pai_cup=vars(3);
w_cup=vars(4);
l_cup=vars(5);
output_cup=vars(6);
mc_cup=vars(7);
evf_cup=vars(8);
vf_cup=vars(9);
p1_cup=vars(10);
p1Real_cup=vars(11);
dc_cup=vars(12);
c_cu=vars(13);
r_cu=vars(14);
pai_cu=vars(15);
w_cu=vars(16);
l_cu=vars(17);
output_cu=vars(18);
mc_cu=vars(19);
evf_cu=vars(20);
vf_cu=vars(21);
p1_cu=vars(22);
p1Real_cu=vars(23);
dc_cu=vars(24);
c_ba1p=vars(25);
muz_cup=vars(26);
d_cup=vars(27);
n_cup=vars(28);
paistar_cup=vars(29);
a_cup=vars(30);
sigmap_perturbation=vars(31);
c_ba1=vars(32);
muz_cu=vars(33);
d_cu=vars(34);
n_cu=vars(35);
paistar_cu=vars(36);
a_cu=vars(37);
sigma_perturbation=vars(38);
BETTA=params(1);
B=params(2);
CHI=params(3);
CHI0=params(4);
THETA=params(5);
DELTA=params(6);
ALFA=params(7);
PHI=params(8);
PHIzero=params(9);
ZI=params(10);
KAPAw=params(11);
ETA=params(12);
RHOR=params(13);
PHIpai=params(14);
PHIpai_1=params(15);
PHIy=params(16);
PHIy_1=params(17);
PHIc=params(18);
PHIc_1=params(19);
PHIl=params(20);
NU=params(21);
U0=params(22);
U0d=params(23);
RHOz=params(24);
RHOd=params(25);
RHOn=params(26);
RHOp=params(27);
RHOa=params(28);
Kss=params(29);
OUTPUTss=params(30);
PAIss=params(31);
MUZss=params(32);
Css=params(33);
AA=params(34);
lss=params(35);
Rss=params(36);
Wss=params(37);
full_rows=zeros(103,1);
full_vals=zeros(103,1);
compressed_deriv=zeros(8,1);
compressed_deriv(1)=-(exp(-vf_cu)*exp(c_cu)*exp(d_cu))/(Css^CHI0*((exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))/Css^CHI0)^CHI);
compressed_deriv(2)=(PHIzero*exp(-vf_cu)*exp(d_cu)*exp(l_cu)*exp(n_cu))/(1 - exp(l_cu))^(1/PHI);
compressed_deriv(3)=-(AA*BETTA*exp(-vf_cu)*exp(evf_cu))/(exp(evf_cu)^(1/(ALFA - 1) + 1)*(ALFA - 1));
compressed_deriv(4)=-exp(-vf_cu)*(exp(d_cu)*(((exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))/Css^CHI0)^(1 - CHI)/(CHI - 1) - U0d + (PHIzero*exp(n_cu)*(1 - exp(l_cu))^(1 - 1/PHI))/(1/PHI - 1)) - U0 + (AA*BETTA)/exp(evf_cu)^(1/(ALFA - 1)));
compressed_deriv(5)=(B*exp(-muz_cu)*exp(-vf_cu)*exp(c_ba1)*exp(d_cu))/(Css^CHI0*((exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))/Css^CHI0)^CHI);
compressed_deriv(6)=-(B*exp(-muz_cu)*exp(-vf_cu)*exp(c_ba1)*exp(d_cu))/(Css^CHI0*((exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))/Css^CHI0)^CHI);
compressed_deriv(7)=exp(-vf_cu)*exp(d_cu)*(((exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))/Css^CHI0)^(1 - CHI)/(CHI - 1) - U0d + (PHIzero*exp(n_cu)*(1 - exp(l_cu))^(1 - 1/PHI))/(1/PHI - 1));
compressed_deriv(8)=(PHIzero*exp(-vf_cu)*exp(d_cu)*exp(n_cu)*(1 - exp(l_cu))^(1 - 1/PHI))/(1/PHI - 1);
uncompressed_deriv=compressed_deriv(index.nnz{1,1});
full_vals(1:8)=uncompressed_deriv;
full_rows(1:8)=index.loc{1,1};
compressed_deriv=zeros(6,1);
compressed_deriv(1)=-(CHI*PHIzero*exp(-w_cu)*exp(c_cu)*exp(n_cu)*((exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))/Css^CHI0)^(CHI - 1)*(KAPAw - 1))/(1 - exp(l_cu))^(1/PHI);
compressed_deriv(2)=-exp(-w_cu)*(KAPAw*Wss - (Css^CHI0*PHIzero*exp(n_cu)*((exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))/Css^CHI0)^CHI*(KAPAw - 1))/(1 - exp(l_cu))^(1/PHI));
compressed_deriv(3)=-(Css^CHI0*PHIzero*exp(-w_cu)*exp(l_cu)*exp(n_cu)*((exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))/Css^CHI0)^CHI*(KAPAw - 1))/(PHI*(1 - exp(l_cu))^(1/PHI + 1));
compressed_deriv(4)=(B*CHI*PHIzero*exp(-muz_cu)*exp(-w_cu)*exp(c_ba1)*exp(n_cu)*((exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))/Css^CHI0)^(CHI - 1)*(KAPAw - 1))/(1 - exp(l_cu))^(1/PHI);
compressed_deriv(5)=-(B*CHI*PHIzero*exp(-muz_cu)*exp(-w_cu)*exp(c_ba1)*exp(n_cu)*((exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))/Css^CHI0)^(CHI - 1)*(KAPAw - 1))/(1 - exp(l_cu))^(1/PHI);
compressed_deriv(6)=-(Css^CHI0*PHIzero*exp(-w_cu)*exp(n_cu)*((exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))/Css^CHI0)^CHI*(KAPAw - 1))/(1 - exp(l_cu))^(1/PHI);
uncompressed_deriv=compressed_deriv(index.nnz{2,1});
full_vals(9:14)=uncompressed_deriv;
full_rows(9:14)=index.loc{2,1};
compressed_deriv=zeros(11,1);
compressed_deriv(1)=-(BETTA*CHI*exp(-d_cu)*exp(-pai_cup)*exp(c_cup)*exp(d_cup)*exp(r_cu)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^(CHI + 1);
compressed_deriv(2)=-(BETTA*exp(-d_cu)*exp(-pai_cup)*exp(d_cup)*exp(r_cu)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI;
compressed_deriv(3)=-(AA*ALFA*BETTA*exp(-d_cu)*exp(-pai_cup)*exp(-vf_cup)*exp(d_cup)*exp(r_cu)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^(ALFA - 1))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI);
compressed_deriv(4)=(BETTA*CHI*exp(-d_cu)*exp(-pai_cup)*exp(c_cu)*exp(d_cup)*exp(r_cu)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^(CHI - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI + (B*BETTA*CHI*exp(-d_cu)*exp(-muz_cup)*exp(-pai_cup)*exp(c_cu)*exp(d_cup)*exp(r_cu)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^(CHI + 1);
compressed_deriv(5)=(BETTA*exp(-d_cu)*exp(-pai_cup)*exp(d_cup)*exp(r_cu)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI;
compressed_deriv(6)=-(AA*ALFA*BETTA*exp(-d_cu)*exp(-pai_cup)*exp(-vf_cup)*exp(d_cup)*exp(evf_cu)*exp(r_cu)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^(ALFA - 1))/(exp(evf_cu)^(1/(ALFA - 1) + 1)*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))*(ALFA - 1)*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI);
compressed_deriv(7)=- (BETTA*exp(-d_cu)*exp(-pai_cup)*exp(d_cup)*exp(muz_cup)*exp(r_cu)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0 - 1)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*(CHI0 - CHI*(CHI0 - 1))*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI - (B*BETTA*CHI*exp(-d_cu)*exp(-muz_cup)*exp(-pai_cup)*exp(c_cu)*exp(d_cup)*exp(r_cu)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^(CHI + 1) - (AA*ALFA*BETTA*exp(-d_cu)*exp(-pai_cup)*exp(-vf_cup)*exp(d_cup)*exp(muz_cup)*exp(r_cu)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(CHI - 1)*(CHI0 - 1)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^(ALFA - 1))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1) + 1)*(exp(c_cup) - B*exp(-muz_cup)*... 
 exp(c_cu))^CHI);
compressed_deriv(8)=(BETTA*exp(-d_cu)*exp(-pai_cup)*exp(d_cup)*exp(r_cu)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI;
compressed_deriv(9)=-(B*BETTA*CHI*exp(-d_cu)*exp(-muz_cu)*exp(-pai_cup)*exp(c_ba1)*exp(d_cup)*exp(r_cu)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^(CHI - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI;
compressed_deriv(10)=(B*BETTA*CHI*exp(-d_cu)*exp(-muz_cu)*exp(-pai_cup)*exp(c_ba1)*exp(d_cup)*exp(r_cu)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^(CHI - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI;
compressed_deriv(11)=-(BETTA*exp(-d_cu)*exp(-pai_cup)*exp(d_cup)*exp(r_cu)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI;
uncompressed_deriv=compressed_deriv(index.nnz{3,1});
full_vals(15:25)=uncompressed_deriv;
full_rows(15:25)=index.loc{3,1};
compressed_deriv=zeros(4,1);
compressed_deriv(1)=-(exp(-a_cu)*exp(-mc_cu)*exp(w_cu)*exp(l_cu)^THETA)/(Kss^THETA*(THETA - 1));
compressed_deriv(2)=-(THETA*exp(-a_cu)*exp(-mc_cu)*exp(l_cu)*exp(w_cu)*exp(l_cu)^(THETA - 1))/(Kss^THETA*(THETA - 1));
compressed_deriv(3)=(exp(-a_cu)*exp(-mc_cu)*exp(w_cu)*exp(l_cu)^THETA)/(Kss^THETA*(THETA - 1));
compressed_deriv(4)=(exp(-a_cu)*exp(-mc_cu)*exp(w_cu)*exp(l_cu)^THETA)/(Kss^THETA*(THETA - 1));
uncompressed_deriv=compressed_deriv(index.nnz{4,1});
full_vals(26:29)=uncompressed_deriv;
full_rows(26:29)=index.loc{4,1};
compressed_deriv=zeros(14,1);
compressed_deriv(1)=-(BETTA*CHI*ZI*exp(-d_cu)*exp(-mc_cu)*exp(-output_cu)*exp(c_cup)*exp(d_cup)*exp(muz_cup)*exp(output_cup)*exp(pai_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*(exp(pai_cup)/PAIss^NU - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(ETA*PAIss^NU*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^(CHI + 1));
compressed_deriv(2)=(exp(-mc_cu)*((BETTA*ZI*exp(-d_cu)*exp(-output_cu)*exp(2*pai_cup)*exp(d_cup)*exp(muz_cup)*exp(output_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(PAIss^(2*NU)*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI) + (BETTA*ZI*exp(-d_cu)*exp(-output_cu)*exp(d_cup)*exp(muz_cup)*exp(output_cup)*exp(pai_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*(exp(pai_cup)/PAIss^NU - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(PAIss^NU*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI)))/ETA;
compressed_deriv(3)=(BETTA*ZI*exp(-d_cu)*exp(-mc_cu)*exp(-output_cu)*exp(d_cup)*exp(muz_cup)*exp(output_cup)*exp(pai_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*(exp(pai_cup)/PAIss^NU - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(ETA*PAIss^NU*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI);
compressed_deriv(4)=-(AA*ALFA*BETTA*ZI*exp(-d_cu)*exp(-mc_cu)*exp(-output_cu)*exp(-vf_cup)*exp(d_cup)*exp(muz_cup)*exp(output_cup)*exp(pai_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*(exp(pai_cup)/PAIss^NU - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^(ALFA - 1))/(ETA*PAIss^NU*exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI);
compressed_deriv(5)=(exp(-mc_cu)*((B*BETTA*CHI*ZI*exp(-d_cu)*exp(-output_cu)*exp(c_cu)*exp(d_cup)*exp(output_cup)*exp(pai_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*(exp(pai_cup)/PAIss^NU - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(PAIss^NU*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^(CHI + 1)) + (BETTA*CHI*ZI*exp(-d_cu)*exp(-output_cu)*exp(c_cu)*exp(d_cup)*exp(muz_cup)*exp(output_cup)*exp(pai_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^(CHI - 1)*(exp(pai_cup)/PAIss^NU - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(PAIss^NU*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI)))/ETA;
compressed_deriv(6)=-(exp(-mc_cu)*((ZI*exp(2*pai_cu))/PAIss^(2*NU) + (ZI*exp(pai_cu)*(exp(pai_cu)/PAIss^NU - 1))/PAIss^NU))/ETA;
compressed_deriv(7)=-(BETTA*ZI*exp(-d_cu)*exp(-mc_cu)*exp(-output_cu)*exp(d_cup)*exp(muz_cup)*exp(output_cup)*exp(pai_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*(exp(pai_cup)/PAIss^NU - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(ETA*PAIss^NU*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI);
compressed_deriv(8)=(exp(-mc_cu)*(ETA + (ZI*exp(pai_cu)*(exp(pai_cu)/PAIss^NU - 1))/PAIss^NU - (BETTA*ZI*exp(-d_cu)*exp(-output_cu)*exp(d_cup)*exp(muz_cup)*exp(output_cup)*exp(pai_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*(exp(pai_cup)/PAIss^NU - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(PAIss^NU*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI) - 1))/ETA;
compressed_deriv(9)=-(AA*ALFA*BETTA*ZI*exp(-d_cu)*exp(-mc_cu)*exp(-output_cu)*exp(-vf_cup)*exp(d_cup)*exp(evf_cu)*exp(muz_cup)*exp(output_cup)*exp(pai_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*(exp(pai_cup)/PAIss^NU - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^(ALFA - 1))/(ETA*PAIss^NU*exp(evf_cu)^(1/(ALFA - 1) + 1)*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))*(ALFA - 1)*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI);
compressed_deriv(10)=-(exp(-mc_cu)*((BETTA*ZI*exp(-d_cu)*exp(2*muz_cup)*exp(-output_cu)*exp(d_cup)*exp(output_cup)*exp(pai_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0 - 1)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*(CHI0 - CHI*(CHI0 - 1))*(exp(pai_cup)/PAIss^NU - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(PAIss^NU*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI) - (BETTA*ZI*exp(-d_cu)*exp(-output_cu)*exp(d_cup)*exp(muz_cup)*exp(output_cup)*exp(pai_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*(exp(pai_cup)/PAIss^NU - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(PAIss^NU*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI) + (B*BETTA*CHI*ZI*exp(-d_cu)*exp(-output_cu)*exp(c_cu)*exp(d_cup)*exp(output_cup)*exp(pai_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*(exp(pai_cup)/PAIss^NU - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI -... 
  1)*(CHI0 - 1))))^ALFA)/(PAIss^NU*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^(CHI + 1)) + (AA*ALFA*BETTA*ZI*exp(-d_cu)*exp(2*muz_cup)*exp(-output_cu)*exp(-vf_cup)*exp(d_cup)*exp(output_cup)*exp(pai_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(CHI - 1)*(CHI0 - 1)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*(exp(pai_cup)/PAIss^NU - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^(ALFA - 1))/(PAIss^NU*exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1) + 1)*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI)))/ETA;
compressed_deriv(11)=(BETTA*ZI*exp(-d_cu)*exp(-mc_cu)*exp(-output_cu)*exp(d_cup)*exp(muz_cup)*exp(output_cup)*exp(pai_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*(exp(pai_cup)/PAIss^NU - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(ETA*PAIss^NU*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI);
compressed_deriv(12)=-(B*BETTA*CHI*ZI*exp(-d_cu)*exp(-mc_cu)*exp(-muz_cu)*exp(-output_cu)*exp(c_ba1)*exp(d_cup)*exp(muz_cup)*exp(output_cup)*exp(pai_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^(CHI - 1)*(exp(pai_cup)/PAIss^NU - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(ETA*PAIss^NU*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI);
compressed_deriv(13)=(B*BETTA*CHI*ZI*exp(-d_cu)*exp(-mc_cu)*exp(-muz_cu)*exp(-output_cu)*exp(c_ba1)*exp(d_cup)*exp(muz_cup)*exp(output_cup)*exp(pai_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^(CHI - 1)*(exp(pai_cup)/PAIss^NU - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(ETA*PAIss^NU*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI);
compressed_deriv(14)=-(BETTA*ZI*exp(-d_cu)*exp(-mc_cu)*exp(-output_cu)*exp(d_cup)*exp(muz_cup)*exp(output_cup)*exp(pai_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*(exp(pai_cup)/PAIss^NU - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(ETA*PAIss^NU*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI);
uncompressed_deriv=compressed_deriv(index.nnz{5,1});
full_vals(30:43)=uncompressed_deriv;
full_rows(30:43)=index.loc{5,1};
compressed_deriv=zeros(14,1);
compressed_deriv(1)=PHIc_1*Rss*exp(c_cup)*exp(PHIl*log(exp(l_cu)/lss) + PHIc*(log(exp(muz_cu)) - log(MUZss) - exp(c_ba1) + exp(c_cu)) + PHIc_1*(log(exp(muz_cup)) - log(MUZss) - exp(c_ba1p) + exp(c_cup)) - PHIpai*(log(exp(paistar_cu)) - log(exp(pai_cu)) + log(PAIss)) - PHIpai_1*(log(exp(paistar_cup)) - log(exp(pai_cup)) + log(PAIss)) + PHIy*log(exp(output_cu)/OUTPUTss) + PHIy_1*log(exp(output_cup)/OUTPUTss));
compressed_deriv(2)=PHIpai_1*Rss*exp(PHIl*log(exp(l_cu)/lss) + PHIc*(log(exp(muz_cu)) - log(MUZss) - exp(c_ba1) + exp(c_cu)) + PHIc_1*(log(exp(muz_cup)) - log(MUZss) - exp(c_ba1p) + exp(c_cup)) - PHIpai*(log(exp(paistar_cu)) - log(exp(pai_cu)) + log(PAIss)) - PHIpai_1*(log(exp(paistar_cup)) - log(exp(pai_cup)) + log(PAIss)) + PHIy*log(exp(output_cu)/OUTPUTss) + PHIy_1*log(exp(output_cup)/OUTPUTss));
compressed_deriv(3)=PHIy_1*Rss*exp(PHIl*log(exp(l_cu)/lss) + PHIc*(log(exp(muz_cu)) - log(MUZss) - exp(c_ba1) + exp(c_cu)) + PHIc_1*(log(exp(muz_cup)) - log(MUZss) - exp(c_ba1p) + exp(c_cup)) - PHIpai*(log(exp(paistar_cu)) - log(exp(pai_cu)) + log(PAIss)) - PHIpai_1*(log(exp(paistar_cup)) - log(exp(pai_cup)) + log(PAIss)) + PHIy*log(exp(output_cu)/OUTPUTss) + PHIy_1*log(exp(output_cup)/OUTPUTss));
compressed_deriv(4)=PHIc*Rss*exp(c_cu)*exp(PHIl*log(exp(l_cu)/lss) + PHIc*(log(exp(muz_cu)) - log(MUZss) - exp(c_ba1) + exp(c_cu)) + PHIc_1*(log(exp(muz_cup)) - log(MUZss) - exp(c_ba1p) + exp(c_cup)) - PHIpai*(log(exp(paistar_cu)) - log(exp(pai_cu)) + log(PAIss)) - PHIpai_1*(log(exp(paistar_cup)) - log(exp(pai_cup)) + log(PAIss)) + PHIy*log(exp(output_cu)/OUTPUTss) + PHIy_1*log(exp(output_cup)/OUTPUTss));
compressed_deriv(5)=-exp(r_cu);
compressed_deriv(6)=PHIpai*Rss*exp(PHIl*log(exp(l_cu)/lss) + PHIc*(log(exp(muz_cu)) - log(MUZss) - exp(c_ba1) + exp(c_cu)) + PHIc_1*(log(exp(muz_cup)) - log(MUZss) - exp(c_ba1p) + exp(c_cup)) - PHIpai*(log(exp(paistar_cu)) - log(exp(pai_cu)) + log(PAIss)) - PHIpai_1*(log(exp(paistar_cup)) - log(exp(pai_cup)) + log(PAIss)) + PHIy*log(exp(output_cu)/OUTPUTss) + PHIy_1*log(exp(output_cup)/OUTPUTss));
compressed_deriv(7)=PHIl*Rss*exp(PHIl*log(exp(l_cu)/lss) + PHIc*(log(exp(muz_cu)) - log(MUZss) - exp(c_ba1) + exp(c_cu)) + PHIc_1*(log(exp(muz_cup)) - log(MUZss) - exp(c_ba1p) + exp(c_cup)) - PHIpai*(log(exp(paistar_cu)) - log(exp(pai_cu)) + log(PAIss)) - PHIpai_1*(log(exp(paistar_cup)) - log(exp(pai_cup)) + log(PAIss)) + PHIy*log(exp(output_cu)/OUTPUTss) + PHIy_1*log(exp(output_cup)/OUTPUTss));
compressed_deriv(8)=PHIy*Rss*exp(PHIl*log(exp(l_cu)/lss) + PHIc*(log(exp(muz_cu)) - log(MUZss) - exp(c_ba1) + exp(c_cu)) + PHIc_1*(log(exp(muz_cup)) - log(MUZss) - exp(c_ba1p) + exp(c_cup)) - PHIpai*(log(exp(paistar_cu)) - log(exp(pai_cu)) + log(PAIss)) - PHIpai_1*(log(exp(paistar_cup)) - log(exp(pai_cup)) + log(PAIss)) + PHIy*log(exp(output_cu)/OUTPUTss) + PHIy_1*log(exp(output_cup)/OUTPUTss));
compressed_deriv(9)=-PHIc_1*Rss*exp(c_ba1p)*exp(PHIl*log(exp(l_cu)/lss) + PHIc*(log(exp(muz_cu)) - log(MUZss) - exp(c_ba1) + exp(c_cu)) + PHIc_1*(log(exp(muz_cup)) - log(MUZss) - exp(c_ba1p) + exp(c_cup)) - PHIpai*(log(exp(paistar_cu)) - log(exp(pai_cu)) + log(PAIss)) - PHIpai_1*(log(exp(paistar_cup)) - log(exp(pai_cup)) + log(PAIss)) + PHIy*log(exp(output_cu)/OUTPUTss) + PHIy_1*log(exp(output_cup)/OUTPUTss));
compressed_deriv(10)=PHIc_1*Rss*exp(PHIl*log(exp(l_cu)/lss) + PHIc*(log(exp(muz_cu)) - log(MUZss) - exp(c_ba1) + exp(c_cu)) + PHIc_1*(log(exp(muz_cup)) - log(MUZss) - exp(c_ba1p) + exp(c_cup)) - PHIpai*(log(exp(paistar_cu)) - log(exp(pai_cu)) + log(PAIss)) - PHIpai_1*(log(exp(paistar_cup)) - log(exp(pai_cup)) + log(PAIss)) + PHIy*log(exp(output_cu)/OUTPUTss) + PHIy_1*log(exp(output_cup)/OUTPUTss));
compressed_deriv(11)=-PHIpai_1*Rss*exp(PHIl*log(exp(l_cu)/lss) + PHIc*(log(exp(muz_cu)) - log(MUZss) - exp(c_ba1) + exp(c_cu)) + PHIc_1*(log(exp(muz_cup)) - log(MUZss) - exp(c_ba1p) + exp(c_cup)) - PHIpai*(log(exp(paistar_cu)) - log(exp(pai_cu)) + log(PAIss)) - PHIpai_1*(log(exp(paistar_cup)) - log(exp(pai_cup)) + log(PAIss)) + PHIy*log(exp(output_cu)/OUTPUTss) + PHIy_1*log(exp(output_cup)/OUTPUTss));
compressed_deriv(12)=-PHIc*Rss*exp(c_ba1)*exp(PHIl*log(exp(l_cu)/lss) + PHIc*(log(exp(muz_cu)) - log(MUZss) - exp(c_ba1) + exp(c_cu)) + PHIc_1*(log(exp(muz_cup)) - log(MUZss) - exp(c_ba1p) + exp(c_cup)) - PHIpai*(log(exp(paistar_cu)) - log(exp(pai_cu)) + log(PAIss)) - PHIpai_1*(log(exp(paistar_cup)) - log(exp(pai_cup)) + log(PAIss)) + PHIy*log(exp(output_cu)/OUTPUTss) + PHIy_1*log(exp(output_cup)/OUTPUTss));
compressed_deriv(13)=PHIc*Rss*exp(PHIl*log(exp(l_cu)/lss) + PHIc*(log(exp(muz_cu)) - log(MUZss) - exp(c_ba1) + exp(c_cu)) + PHIc_1*(log(exp(muz_cup)) - log(MUZss) - exp(c_ba1p) + exp(c_cup)) - PHIpai*(log(exp(paistar_cu)) - log(exp(pai_cu)) + log(PAIss)) - PHIpai_1*(log(exp(paistar_cup)) - log(exp(pai_cup)) + log(PAIss)) + PHIy*log(exp(output_cu)/OUTPUTss) + PHIy_1*log(exp(output_cup)/OUTPUTss));
compressed_deriv(14)=-PHIpai*Rss*exp(PHIl*log(exp(l_cu)/lss) + PHIc*(log(exp(muz_cu)) - log(MUZss) - exp(c_ba1) + exp(c_cu)) + PHIc_1*(log(exp(muz_cup)) - log(MUZss) - exp(c_ba1p) + exp(c_cup)) - PHIpai*(log(exp(paistar_cu)) - log(exp(pai_cu)) + log(PAIss)) - PHIpai_1*(log(exp(paistar_cup)) - log(exp(pai_cup)) + log(PAIss)) + PHIy*log(exp(output_cu)/OUTPUTss) + PHIy_1*log(exp(output_cup)/OUTPUTss));
uncompressed_deriv=compressed_deriv(index.nnz{6,1});
full_vals(44:57)=uncompressed_deriv;
full_rows(44:57)=index.loc{6,1};
compressed_deriv=zeros(3,1);
compressed_deriv(1)=-(exp(c_cu)*exp(output_cu)*((ZI*(exp(pai_cu)/PAIss^NU - 1)^2)/2 - 1))/(exp(c_cu) + DELTA*Kss)^2;
compressed_deriv(2)=(ZI*exp(output_cu)*exp(pai_cu)*(exp(pai_cu)/PAIss^NU - 1))/(PAIss^NU*(exp(c_cu) + DELTA*Kss));
compressed_deriv(3)=(exp(output_cu)*((ZI*(exp(pai_cu)/PAIss^NU - 1)^2)/2 - 1))/(exp(c_cu) + DELTA*Kss);
uncompressed_deriv=compressed_deriv(index.nnz{7,1});
full_vals(58:60)=uncompressed_deriv;
full_rows(58:60)=index.loc{7,1};
compressed_deriv=zeros(3,1);
compressed_deriv(1)=-(Kss^THETA*exp(-output_cu)*exp(a_cu)*exp(l_cu)*(THETA - 1))/exp(l_cu)^THETA;
compressed_deriv(2)=-Kss^THETA*exp(-output_cu)*exp(a_cu)*exp(l_cu)^(1 - THETA);
compressed_deriv(3)=Kss^THETA*exp(-output_cu)*exp(a_cu)*exp(l_cu)^(1 - THETA);
uncompressed_deriv=compressed_deriv(index.nnz{8,1});
full_vals(61:63)=uncompressed_deriv;
full_rows(61:63)=index.loc{8,1};
compressed_deriv=zeros(3,1);
compressed_deriv(1)=-(exp(-evf_cu)*exp(vf_cup)*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))*(ALFA - 1))/(AA*((exp(vf_cup)*exp(muz_cup)^((CHI - 1)*(CHI0 - 1)))/AA)^ALFA);
compressed_deriv(2)=-exp(-evf_cu)*((exp(vf_cup)*exp(muz_cup)^((CHI - 1)*(CHI0 - 1)))/AA)^(1 - ALFA);
compressed_deriv(3)=-(exp(-evf_cu)*exp(muz_cup)*exp(vf_cup)*exp(muz_cup)^((CHI - 1)*(CHI0 - 1) - 1)*(ALFA - 1)*(CHI - 1)*(CHI0 - 1))/(AA*((exp(vf_cup)*exp(muz_cup)^((CHI - 1)*(CHI0 - 1)))/AA)^ALFA);
uncompressed_deriv=compressed_deriv(index.nnz{9,1});
full_vals(64:66)=uncompressed_deriv;
full_rows(64:66)=index.loc{9,1};
compressed_deriv=zeros(11,1);
compressed_deriv(1)=-(BETTA*CHI*exp(-d_cu)*exp(-p1_cu)*exp(-pai_cup)*exp(c_cup)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^(CHI + 1);
compressed_deriv(2)=-(BETTA*exp(-d_cu)*exp(-p1_cu)*exp(-pai_cup)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI;
compressed_deriv(3)=-(AA*ALFA*BETTA*exp(-d_cu)*exp(-p1_cu)*exp(-pai_cup)*exp(-vf_cup)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^(ALFA - 1))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI);
compressed_deriv(4)=(BETTA*CHI*exp(-d_cu)*exp(-p1_cu)*exp(-pai_cup)*exp(c_cu)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^(CHI - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI + (B*BETTA*CHI*exp(-d_cu)*exp(-muz_cup)*exp(-p1_cu)*exp(-pai_cup)*exp(c_cu)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^(CHI + 1);
compressed_deriv(5)=-(AA*ALFA*BETTA*exp(-d_cu)*exp(-p1_cu)*exp(-pai_cup)*exp(-vf_cup)*exp(d_cup)*exp(evf_cu)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^(ALFA - 1))/(exp(evf_cu)^(1/(ALFA - 1) + 1)*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))*(ALFA - 1)*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI);
compressed_deriv(6)=-(BETTA*exp(-d_cu)*exp(-p1_cu)*exp(-pai_cup)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI;
compressed_deriv(7)=- (BETTA*exp(-d_cu)*exp(-p1_cu)*exp(-pai_cup)*exp(d_cup)*exp(muz_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0 - 1)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*(CHI0 - CHI*(CHI0 - 1))*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI - (B*BETTA*CHI*exp(-d_cu)*exp(-muz_cup)*exp(-p1_cu)*exp(-pai_cup)*exp(c_cu)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^(CHI + 1) - (AA*ALFA*BETTA*exp(-d_cu)*exp(-p1_cu)*exp(-pai_cup)*exp(-vf_cup)*exp(d_cup)*exp(muz_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(CHI - 1)*(CHI0 - 1)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^(ALFA - 1))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1) + 1)*(exp(c_cup) - B*exp(-... 
 muz_cup)*exp(c_cu))^CHI);
compressed_deriv(8)=(BETTA*exp(-d_cu)*exp(-p1_cu)*exp(-pai_cup)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI;
compressed_deriv(9)=-(B*BETTA*CHI*exp(-d_cu)*exp(-muz_cu)*exp(-p1_cu)*exp(-pai_cup)*exp(c_ba1)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^(CHI - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI;
compressed_deriv(10)=(B*BETTA*CHI*exp(-d_cu)*exp(-muz_cu)*exp(-p1_cu)*exp(-pai_cup)*exp(c_ba1)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^(CHI - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI;
compressed_deriv(11)=-(BETTA*exp(-d_cu)*exp(-p1_cu)*exp(-pai_cup)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI;
uncompressed_deriv=compressed_deriv(index.nnz{10,1});
full_vals(67:77)=uncompressed_deriv;
full_rows(67:77)=index.loc{10,1};
compressed_deriv=zeros(10,1);
compressed_deriv(1)=-(BETTA*CHI*exp(-d_cu)*exp(-p1Real_cu)*exp(c_cup)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^(CHI + 1);
compressed_deriv(2)=-(AA*ALFA*BETTA*exp(-d_cu)*exp(-p1Real_cu)*exp(-vf_cup)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^(ALFA - 1))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI);
compressed_deriv(3)=(BETTA*CHI*exp(-d_cu)*exp(-p1Real_cu)*exp(c_cu)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^(CHI - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI + (B*BETTA*CHI*exp(-d_cu)*exp(-muz_cup)*exp(-p1Real_cu)*exp(c_cu)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^(CHI + 1);
compressed_deriv(4)=-(AA*ALFA*BETTA*exp(-d_cu)*exp(-p1Real_cu)*exp(-vf_cup)*exp(d_cup)*exp(evf_cu)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^(ALFA - 1))/(exp(evf_cu)^(1/(ALFA - 1) + 1)*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))*(ALFA - 1)*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI);
compressed_deriv(5)=-(BETTA*exp(-d_cu)*exp(-p1Real_cu)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI;
compressed_deriv(6)=- (BETTA*exp(-d_cu)*exp(-p1Real_cu)*exp(d_cup)*exp(muz_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0 - 1)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*(CHI0 - CHI*(CHI0 - 1))*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI - (B*BETTA*CHI*exp(-d_cu)*exp(-muz_cup)*exp(-p1Real_cu)*exp(c_cu)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^(CHI + 1) - (AA*ALFA*BETTA*exp(-d_cu)*exp(-p1Real_cu)*exp(-vf_cup)*exp(d_cup)*exp(muz_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(CHI - 1)*(CHI0 - 1)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^(ALFA - 1))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1) + 1)*(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI);
compressed_deriv(7)=(BETTA*exp(-d_cu)*exp(-p1Real_cu)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI;
compressed_deriv(8)=-(B*BETTA*CHI*exp(-d_cu)*exp(-muz_cu)*exp(-p1Real_cu)*exp(c_ba1)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^(CHI - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI;
compressed_deriv(9)=(B*BETTA*CHI*exp(-d_cu)*exp(-muz_cu)*exp(-p1Real_cu)*exp(c_ba1)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^(CHI - 1)*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI;
compressed_deriv(10)=-(BETTA*exp(-d_cu)*exp(-p1Real_cu)*exp(d_cup)*exp(muz_cup)^(CHI*(CHI0 - 1) - CHI0)*(exp(c_cu) - B*exp(-muz_cu)*exp(c_ba1))^CHI*((AA*exp(-vf_cup))/(exp(evf_cu)^(1/(ALFA - 1))*exp(muz_cup)^((CHI - 1)*(CHI0 - 1))))^ALFA)/(exp(c_cup) - B*exp(-muz_cup)*exp(c_cu))^CHI;
uncompressed_deriv=compressed_deriv(index.nnz{11,1});
full_vals(78:87)=uncompressed_deriv;
full_rows(78:87)=index.loc{11,1};
compressed_deriv=zeros(4,1);
compressed_deriv(1)=1;
compressed_deriv(2)=-1;
compressed_deriv(3)=-1;
compressed_deriv(4)=1;
uncompressed_deriv=compressed_deriv(index.nnz{12,1});
full_vals(88:91)=uncompressed_deriv;
full_rows(88:91)=index.loc{12,1};
compressed_deriv=zeros(2,1);
compressed_deriv(1)=exp(-c_ba1p)*exp(c_cu);
compressed_deriv(2)=-exp(-c_ba1p)*exp(c_cu);
uncompressed_deriv=compressed_deriv(index.nnz{13,1});
full_vals(92:93)=uncompressed_deriv;
full_rows(92:93)=index.loc{13,1};
compressed_deriv=zeros(2,1);
compressed_deriv(1)=-1;
compressed_deriv(2)=RHOz;
uncompressed_deriv=compressed_deriv(index.nnz{14,1});
full_vals(94:95)=uncompressed_deriv;
full_rows(94:95)=index.loc{14,1};
compressed_deriv=zeros(2,1);
compressed_deriv(1)=-1;
compressed_deriv(2)=RHOd;
uncompressed_deriv=compressed_deriv(index.nnz{15,1});
full_vals(96:97)=uncompressed_deriv;
full_rows(96:97)=index.loc{15,1};
compressed_deriv=zeros(2,1);
compressed_deriv(1)=-1;
compressed_deriv(2)=RHOn;
uncompressed_deriv=compressed_deriv(index.nnz{16,1});
full_vals(98:99)=uncompressed_deriv;
full_rows(98:99)=index.loc{16,1};
compressed_deriv=zeros(2,1);
compressed_deriv(1)=-1;
compressed_deriv(2)=RHOp;
uncompressed_deriv=compressed_deriv(index.nnz{17,1});
full_vals(100:101)=uncompressed_deriv;
full_rows(100:101)=index.loc{17,1};
compressed_deriv=zeros(2,1);
compressed_deriv(1)=-1;
compressed_deriv(2)=RHOa;
uncompressed_deriv=compressed_deriv(index.nnz{18,1});
full_vals(102:103)=uncompressed_deriv;
full_rows(102:103)=index.loc{18,1};
derivs=sparse(full_rows,ones(length(full_vals),1),full_vals,684,1);
